package com.flxz.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flxz.common.annotation.Log;
import com.flxz.common.core.controller.BaseController;
import com.flxz.common.core.domain.AjaxResult;
import com.flxz.common.enums.BusinessType;
import com.flxz.manage.domain.ManageUserAdmin;
import com.flxz.manage.service.IUserAdminService;
import com.flxz.common.utils.poi.ExcelUtil;
import com.flxz.common.core.page.TableDataInfo;

/**
 * 用户信息(管理员)Controller
 * 
 * @author fl
 * @date 2025-09-12
 */
@RestController
@RequestMapping("/manage/userAdmin")
public class UserAdminController extends BaseController
{
    @Autowired
    private IUserAdminService userAdminService;

    /**
     * 查询用户信息(管理员)列表
     */
    @PreAuthorize("@ss.hasPermi('manage:userAdmin:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManageUserAdmin userAdmin)
    {
        startPage();
        List<ManageUserAdmin> list = userAdminService.selectUserAdminList(userAdmin);
        return getDataTable(list);
    }

    /**
     * 导出用户信息(管理员)列表
     */
    @PreAuthorize("@ss.hasPermi('manage:userAdmin:export')")
    @Log(title = "用户信息(管理员)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManageUserAdmin userAdmin)
    {
        List<ManageUserAdmin> list = userAdminService.selectUserAdminList(userAdmin);
        ExcelUtil<ManageUserAdmin> util = new ExcelUtil<ManageUserAdmin>(ManageUserAdmin.class);
        util.exportExcel(response, list, "用户信息(管理员)数据");
    }

    /**
     * 获取用户信息(管理员)详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:userAdmin:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(userAdminService.selectUserAdminByUserId(userId));
    }

    /**
     * 新增用户信息(管理员)
     */
    @PreAuthorize("@ss.hasPermi('manage:userAdmin:add')")
    @Log(title = "用户信息(管理员)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManageUserAdmin userAdmin)
    {
        return toAjax(userAdminService.insertUserAdmin(userAdmin));
    }

    /**
     * 修改用户信息(管理员)
     */
    @PreAuthorize("@ss.hasPermi('manage:userAdmin:edit')")
    @Log(title = "用户信息(管理员)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManageUserAdmin userAdmin)
    {
        return toAjax(userAdminService.updateUserAdmin(userAdmin));
    }

    /**
     * 删除用户信息(管理员)
     */
    @PreAuthorize("@ss.hasPermi('manage:userAdmin:remove')")
    @Log(title = "用户信息(管理员)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(userAdminService.deleteUserAdminByUserIds(userIds));
    }
}
